package top.xunfong.probe.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import top.xunfong.api.probe.domain.Probe;
import top.xunfong.api.probe.domain.dto.ProbeDTO;
import top.xunfong.probe.mapper.ProbeMapper;
import top.xunfong.probe.service.ProbeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;
import java.util.List;

@Service
public class ProbeServiceImpl extends ServiceImpl<ProbeMapper, Probe> implements ProbeService {

    @Override
    @Transactional
    public void saveProbe(ProbeDTO dto) {
        save(BeanUtil.copyProperties(dto, Probe.class));
    }

    @Override
    @Transactional
    public void batchSaveProbe(Collection<ProbeDTO> probeDTOs) {
        List<Probe> probes = BeanUtil.copyToList(probeDTOs, Probe.class);
        this.getBaseMapper().batchInsert(probes);
//        saveBatch(probes);
    }
}
